import { useEffect } from "react";
import { useNavigate } from "react-router-dom";
import { setNavigate } from "@/lib/navigation";

export default function NavigationSetter() {
  const navigate = useNavigate();
  useEffect(() => {
    setNavigate((to, opts) =>
      navigate(to, { replace: opts?.replace, state: opts?.state })
    );
    // 不做卸载清理也可以，但可选地清理：
    return () => setNavigate(() => {});
  }, [navigate]);
  return null;
}
